package com.fita.entity.order.reverse;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Type;
import org.springframework.web.multipart.MultipartFile;

/**
 * @description: sku
 * @author: 11200
 * @date: 2019/8/21
 */
@Entity
@Table(name = "sku")
@DynamicUpdate
public class Sku {

    @Id
    @GeneratedValue
    private Long id;

    /**
     * 图片
     */
    private String pic;
    
    @Transient
    private MultipartFile picFile;

    /**
     * 标题
     */
    @Column(unique = true)
    private  String title;

    /**
     * 详情
     */
    @Column
    @Type(type = "text")
    private String detail;

    /**
     * 注意事项
     */
    private String attention;

    /**
     * 价格
     */
    private String price;

    /**
     * 类型
     */
    @Enumerated(EnumType.STRING)
    private ReverseOrderType type;

    @Column(name = "is_active")
    private boolean active;

    @Column(name = "is_disabled")
    private boolean disabled;

    /**
     * 是否激活过
     */
    private boolean hasActive;
    /*
     * 排序
     * */
    private Integer sort;
    

    /**
     *
     */
    public Sku() {
    }

    /**
     * 初始化
     */
    public void init() {
        this.disabled = false;
        this.active = false;
        this.hasActive = false;
    }

    /**
     * 验证
     */
    public boolean validate() {

        if (this.type == null){
            return false;
        }
        return true;
    }

    /**
     * 禁用
     * @return
     */
    public Sku delete() {
        this.disabled = true;
        return this;
    }

    /**
     * 上架
     * @return
     */
    public Sku active() {
        this.active = true;
        this.hasActive = true;
        return this;
    }

    /**
     * 下架
     * @return
     */
    public Sku disabled(){
        this.active = false;
        return this;
    }
    
    /**
     * 上移
     * @param sort
     */
    public void up(Integer sort) {
    	this.sort = sort;
    }
    
    /**
     * 下移
     * @param sort
     */
    public void down(Integer sort) {
    	this.sort = sort;
    }
    

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getPic() {
        return pic;
    }
    
    public MultipartFile getPicFile() {
        return picFile;
    }

    public void setPic(String pic) {
        this.pic = pic;
    }
    
    public void setPicFile(MultipartFile picFile) {
        this.picFile = picFile;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDetail() {
        return detail;
    }

    public void setDetail(String detail) {
        this.detail = detail;
    }

    public String getAttention() {
        return attention;
    }

    public void setAttention(String attention) {
        this.attention = attention;
    }

    public String getPrice() {
        return price;
    }

    public void setPrice(String price) {
        this.price = price;
    }

    public ReverseOrderType getType() {
        return type;
    }

    public void setType(ReverseOrderType type) {
        this.type = type;
    }

    public boolean isDisabled() {
        return disabled;
    }

    public void setDisabled(boolean disabled) {
        this.disabled = disabled;
    }

    public boolean isActive() {
        return active;
    }

    public void setActive(boolean active) {
        this.active = active;
    }

    public boolean isHasActive() {
        return hasActive;
    }

    public void setHasActive(boolean hasActive) {
        this.hasActive = hasActive;
    }

	public Integer getSort() {
		return sort;
	}

	public void setSort(Integer sort) {
		this.sort = sort;
	}
    
}
